# 索引：目录，页码
# 快速查询数据 ， 方便
# 索引唯一  哈希表优化
# 索引不唯一    有序 ，二分查找
# 索引完全随机，每次查询扫描数据

import  pandas as pd
s1 = pd.Series([10,20,30],index=list("abc"))
s2 = pd.Series([3,4,5],index=list("bcd"))
# print(s1)
# print(s2)
# print(s1 + s2)
s3 = pd.Series([88,65,46],index=[1,2,3])
# print(s3)
# print(s3.reindex(index=[1,2,3,4,5]))
# print(s3.reindex(index=[1,2,3,4,5],fill_value=0))
s4 = pd.Series([88,65,46],index=[1,2,3])
# 向前填充
# print(s4.reindex(index=[1,2,3,4,5],method='ffill'))
# 向后填充
# print(s4.reindex(index=[1,2,3,4,5],method='bfill'))
# print(s4.reindex(index=[1,4,5,2,3],method='bfill'))
# 成绩表
pd.set_option('display.unicode.east_asian_width',True)
pd.set_option('display.max_columns',500)
pd.set_option('display.width',1000)
data = [[110,89,87],[103, 79, 33],[109, 90, 108]]
index = ['jack','rose','dark']
columns=['c','java','python']
df = pd.DataFrame(data=data,index=index,columns=columns)
# print(df)
# print(df.reindex(index=['jack','rose','dark','zs','ls']))
# print(df.reindex(columns=['c','java','python','web','c++']))
# print(df.reindex(index=['jack','rose','dark','zs','ls'],columns=['c','java','python','web','c++']))
# 设置某列为索引
df = pd.read_excel('./data/1月.xlsx')
# print(df.head())
df = df.set_index(['买家会员名'])
# print(df.head())
# 删除缺失数据之后，重新设置索引
df = pd.read_excel('./data/TB2018.xls')
df = df.dropna().reset_index(drop=True)
print(df)